<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>ManagerManager for Modx: Function reference: Fields </title>
<link href="css/mm.css" rel="stylesheet" type="text/css" />


</head>

<body>

<div id="banner">

</div>


<div id="main">
    <div id="nav">
        <ul>
            <li><a href="index.htm">Introduction</a></li>
            <li><a href="install.htm">Installation</a></li>
            <li><a href="getting-started.htm">Getting started</a></li>
            <li><a href="field-names.htm">Field names</a></li>
            <li>Fields</li>
            <li><a href="tabs.htm">Tabs</a></li>
            <li><a href="widgets.htm">Widgets</a></li>
            <li><a href="sections.htm">Sections</a></li>
            <li><a href="changelog.htm">Changelog</a></li>
        </ul>   
    </div>
    
  <div id="content">
      <h1>Function reference: Fields
      </h1>
      <h2>mm_renameField($field, $newlabel, $roles, $templates, $newhelp)</h2>
    <p>Renames one of the default fields or template variables within the manager. </p>
    <p><strong>$fields: </strong>The name of the fields this should apply to (from table above). Can only accept single field [Required]<br />
        <strong>$newlabel:</strong> The new text for the label[Required]<br />
        <strong>$roles:</strong> comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]<br />
        <strong>$templates:</strong> comma separated list of template IDs this should be applied to. Leave empty (or omit) for all templates [Optional - default is all]<br />
        <strong>$newhelp:</strong> New text for the help icon with this field. The same restriction apply as when using mm_changeFieldHelp directly [Optional - default is leave unchanged]</p>
    <p><code>mm_renameField('longtitle', 'Page heading'); // Rename the longtitle field to &quot;Page heading&quot; for all users</code><code>mm_renameField('longtitle', 'Case study name', '', '3'); // Rename the longtitle field to &quot;Case study name&quot; for documents using template ID &quot;3&quot;</code></p>
    <h2>mm_hideFields($fields,  $roles, $templates)</h2>
    <p>Hides one or more of the default fields within the manager.</p>
    <p> If a field to be hidden is a template variable, it must be prefixed by 'tv'.</p>
    <p><strong>$fields: </strong>The name(s) of the fields this should apply to (from table above). Can  accept multiple fields separated by commas [Required]<br />
        <strong>$roles:</strong> comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]<br />
        <strong>$templates:</strong> comma separated list of template IDs this should be applied to. Leave empty (or omit) for all templates [Optional - default is all]</p>
    <code>mm_hideFields('link_attributes'); // Hide the link_attributes field for all users</code><code>mm_hideFields('alias', '1', '3'); // Hide the alias field for users with role &quot;1&quot; editing documents using template ID &quot;3&quot;</code><code>mm_hideFields('tvmyVar', '2'); // Hide the template variable &quot;myVar&quot; for users with role &quot;2&quot;</code>
    <h2>mm_changeFieldHelp($field,  $helptext, $roles, $templates)</h2>
    <p>Changes the help text that appears next to each field when the [?] icon is clicked.    </p>
    <p>Note that not all fields have help icons, notably  &quot;content&quot; and &quot;editor to use&quot;. In the future we might insert help icons for these missing ones.</p>
    <p><strong>$field: </strong>The name of the fields this should apply to (from table above). Can only accept single field [Required]<br />
        <strong>$helptext:</strong> The new help text that should appear when the help icon is clicked [Required]<br />
        <strong>$roles:</strong> comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]<br />
        <strong>$templates:</strong> comma separated list of template IDs this should be applied to. Leave empty (or omit) for all templates [Optional - default is all]</p>
    <code>mm_changeFieldHelp('pagetitle', 'This text will appear in the browser title bar and bookmarks'); // Change the help text for pagetitle for all users</code><code>mm_changeFieldHelp('alias', 'How the URL will appear', '1'); // Change the help text for alias only for users with role &quot;1&quot;</code>
    <h2>mm_hideTemplates($tplIds,   $roles, $templates)</h2>
    <p>Hides specified templates from the Templates drop down list</p>
    <p><strong>$tplIds: </strong>The IDs of the templates which should be hidden from the templates dropdown. Can  accept multiple fields separated by commas [Required]<br />
        <strong>$roles:</strong> comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]<br />
        <strong>$templates:</strong> comma separated list of template IDs this should be applied to. Leave empty (or omit) for all templates [Optional - default is all]</p>
    <p><code>mm_hideTemplates('0'); // Hide template 0 (blank) from all users</code><code>mm_hideTemplates('0,4', '1'); // Hide templates 0 and 4 from users with role &quot;1&quot;</code></p>
    <h2>mm_inherit($fields, $roles, $templates)</h2>
    <p>Tells one or more fields to inherit their parent document's value (if it exists). </p>
    <p><strong>$fields: </strong>The name(s) of the fields this should apply to (from table above). Can accept multiple fields. [Required]<br />
        <strong>$roles:</strong> comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]<br />
        <strong>$templates: </strong>comma separated list of template IDs this should be applied to. Leave empty (or omit) for all templates [Optional - default is all]</p>
    <code>mm_inherit('pagetitle', '0,1'); // Inherit parent's pagetitle when users with role 0 or 1 are editing </code><code>mm_inherit('pagetitle,longtitle'); // Inherit parent's pagetitle and longtitle for all users</code>
    <p>Note: this currently only works for text input fields</p>
    <h2>mm_default($field, $value, $roles, $templates, $eval)</h2>
    <p>Provides a default value for specific fields in new documents / folders. Supports:</p>
    <ul>
      <li><strong>pub_date</strong> - takes a PHP date object (Unix timestamp) to set the default publish date. If no value supplied, will be set to current date and time.</li>
      <li><strong>unpub_date</strong> - takes a PHP date object (Unix timestamp) to set the default unpublish date. If no value set, will be set to current date and time.</li>
      <li><strong>published</strong> - should &quot;published&quot; be checked? Takes  boolean value. Note that if this conflicts with the pub/unpub dates, this may be overriden by Modx when the page is saved</li>
      <li><strong>hide_menu</strong> - should &quot;show in menu&quot; be unchecked? Takes  boolean value.</li>
      <li><strong>show_in_menu</strong> - should &quot;show in menu&quot; be checked? Takes  boolean value (opposite of hide_menu)</li>
      <li><strong>searchable</strong> - should &quot;searchable&quot; be checked? Takes  boolean value.</li>
      <li><strong>cacheable</strong> - should &quot;cacheable&quot; be checked? Takes  boolean value.</li>
      <li><strong>clear_cache</strong> - should &quot;empty cache&quot; be checked? Takes  boolean value.</li>
      <li><strong>is_folder</strong> - should &quot;container&quot; be checked? Takes  boolean value.</li>
      <li><strong>is_richtext</strong> - should &quot;rich text&quot; be checked? If set to false, the page will automatically also set the &quot;which_editor&quot; field to none, and reload the page so this takes effect. Takes  boolean value.</li>
      <li><strong>log</strong> -   should &quot;log&quot; be checked? Takes  boolean value.</li>
      <li><strong>content_type</strong> - default internet media (MIME) type, e.g. 'text/xml'</li>
    </ul>
    <p><strong>$field: </strong>The name(s) of the field this should apply to (from table above). Currently accepts 'pub_date' or 'unpub_date' [Required]<br />
        <strong>$value: </strong>The default value for the field specified. If none is supplied the current date/time will be used. A static value can be supplied as a string, or PHP code (to calculate alternative dates) can be supplied if the eval parameter is set to true [Optional]<br />
        <strong>$roles:</strong> comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]<br />
        <strong>$templates:</strong> comma separated list of template IDs this should be applied to. Leave empty (or omit) for all templates [Optional - default is all]<br />
        <strong>$eval:</strong> Should the value be evaluated as PHP code? Boolean [Optional - default is false]</p>
    <code>mm_default('pub_date'); // Always set the publish date on new documents to the current date and time</code><code>mm_default('unpub_date', 'return date(&quot;d-m-Y H:i:s&quot;, now()+(60*60*24*28);', '', '4', true); // Automatically set the unpublish date to be four weeks in the future for documents with a template ID of &quot;4&quot;</code>
    <p></p>
    <h2>mm_synch_fields($fields,  $roles, $templates)</h2>
    <p>Synchronises the values of the specified fields at edit time - e.g. for making sure pagetitle and menutitle automatically read the same, particularly if one value is hidden. Works only with text inputs. </p>
    <p><strong>$fields: </strong>The name(s) of the fields that should be synched (from table above). Requires a minimum of 2 field names, comma separated [Required]<br />
        <strong>$roles:</strong> comma separated list of role IDs this should be applied to. Leave empty (or omit) for all roles [Optional - default is all]<br />
        <strong>$templates:</strong> comma separated list of template IDs this should be applied to. Leave empty (or omit) for all templates [Optional - default is all]<br />
    </p>
    <p><code>mm_synch_fields('pagetitle,menutitle,longtitle'); // Make the contents of these three fields always equal for all users and all documents </code></p>
    <p></p>
    <p>&nbsp;</p>
  </div>
</div>
</body>
</html>
